package com.xhsj.user.hr.process.tbLearningGarden.service;

import com.xhsj.user.hr.process.tbLearningGarden.entity.TbLearningGardenContentViewDept;
import com.xhsj.user.hr.process.tbLearningGarden.mapper.TbLearningGardenContentViewDeptMapper;
import com.xhsj.user.hr.process.tbLearningGarden.service.TbLearningGardenContentViewDeptService;
import com.xhsj.user.hr.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
/**
 * <p>
 * 学习园地查看部门 服务实现类
 * </p>
 *
 * @author suxiaolin
 * @since May 27, 2021 3:37:54 AM
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class TbLearningGardenContentViewDeptService extends BaseService<TbLearningGardenContentViewDeptMapper, TbLearningGardenContentViewDept>{
    @Autowired
    private TbLearningGardenContentViewDeptMapper dao;

	/**
	 * 保存
	 * @author suxiaolin
	 * @date May 27, 2021 3:37:54 AM
	 */
    @Override
    public boolean save(TbLearningGardenContentViewDept entity) {
        return super.save(entity);
    }

	/**
	 * 通过id获取数据
	 * @author suxiaolin
	 * @date May 27, 2021 3:37:54 AM
	 */
    @Override
    public TbLearningGardenContentViewDept getById(Serializable id) {
        return super.getById(id);
    }

	/**
	 * 通过id删除数据
	 * @author suxiaolin
	 * @date May 27, 2021 3:37:54 AM
	 */
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

	/**
	 * 分页查询数据
	 * @author suxiaolin
	 * @date May 27, 2021 3:37:54 AM
	 */
    public IPage<TbLearningGardenContentViewDept> selectPage(Map<String,Object> data) {
        int currentPage=1;
        if (!Objects.isNull(data.get("page"))) {
            currentPage=(Integer) data.get("page");
        }
        int pageSize=20;
        if (!Objects.isNull(data.get("size"))) {
            pageSize=(Integer) data.get("size");
        }

        TbLearningGardenContentViewDept entity = JSON.parseObject(JSON.toJSONString(data), TbLearningGardenContentViewDept.class);
        Page<TbLearningGardenContentViewDept> page = new Page(currentPage,pageSize);
        QueryWrapper<TbLearningGardenContentViewDept> wrapper = new QueryWrapper(entity);
        return super.selectPage(page, wrapper);
    }

	/**
	 * 查询所有数据
	 * @author suxiaolin
	 * @date May 27, 2021 3:37:54 AM
	 */
    @Override
    public List<TbLearningGardenContentViewDept> selectAll() {
        return super.selectAll();
    }


    public void delByDataId(Long id) {
        dao.delByDataId(id);
    }

    public List<Long> getDeptIdByDataId(Long id) {
        return dao.getDeptIdByDataId(id);
    }
}
